<?
error_reporting('E-ALL');
include_once("/var/www/html/new/com.inc.php");
include_once("/var/www/html/new/d/common/func.inc.php");
include_once("/var/www/html/new/d/shops/call/ProductInfoC.php");
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$pid=abs($_REQUEST['pid']);
$p=new ProductInfoC($s,$pid);
$orderMonth=$_REQUEST['orderMonth'];
$str="select t.ddays,f.dhour from uu_products p join uu_jq_ticket t on t.pid=p.id left join uu_land_f f on f.pid=p.id where p.id=$pid limit 1";
$GLOBALS['le']->query($str);
$p_info=$GLOBALS['le']->fetch_assoc();
$monthStart=$orderMonth."-01";
$monthEnd=$orderMonth."-".date("t",strtotime($monthStart));
$mintime=$p->getMinValidTime();
$maxtime=$p->getMaxValidTime();

$begintime=$mintime;
if($begintime<$monthStart){
	$begintime=$monthStart;
}
$endtime=$monthEnd;
/*��ȡԤ������*/
$days=(strtotime($endtime)-strtotime($begintime))/24/3600;
$jsonData=array();
$str="select dprice from uu_priceset  where tid=$pid and pid=".$_SESSION['memberID'];
$GLOBALS['le']->query($str);
$GLOBALS['le']->fetch_assoc();
$dprice=$GLOBALS['le']->f('dprice');
// echo "getPeriodPrice($begintime,$endtime)";
$prices=$p->getPeriodPrice($begintime,$endtime);
// print_r($prices);

if ( (ismobile($_SESSION['account']) && $_SESSION['dtype']==1)
    || $_SESSION['dtype']==5) {
    $price_key = 'lprice';
} else {
    $price_key = 'sprice';
}
foreach($prices as $date=>$price){
	
	$tprice=$price[$price_key];
//	if($_SESSION['dtype']==5){//��ͨ�û�
//		$tprice=$price['lprice']+$dprice;
//	}
	$jsonData[]=array("date"=>$date,"price"=>$tprice/100,"storage"=>$price['storage']);
}
$data["pricelists"]=$jsonData;
$data["about"]["mintime"]=strtotime($mintime);
$data["about"]["maxtime"]=strtotime($maxtime);
if($_REQUEST['datatype']=="jsonp"){
	echo $_REQUEST['callback']."(".json_encode($data).")";
}else{
	echo json_encode($data);
}
?>